home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / live / usr / X11R6 / lib / X11 / xedit / lisp / fun.lsp next >
Encoding:
Lisp/Scheme  |  2002-11-14  |  7.0 KB  |  151 lines

  1. ;;
  2. ;; Copyright (c) 2001 by The XFree86 Project, Inc.
  3. ;;
  4. ;; Permission is hereby granted, free of charge, to any person obtaining a
  5. ;; copy of this software and associated documentation files (the "Software"),
  6. ;; to deal in the Software without restriction, including without limitation
  7. ;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. ;; and/or sell copies of the Software, and to permit persons to whom the
  9. ;; Software is furnished to do so, subject to the following conditions:
  10. ;;
  11. ;; The above copyright notice and this permission notice shall be included in
  12. ;; all copies or substantial portions of the Software.
  13. ;;  
  14. ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. ;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. ;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  17. ;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. ;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
  19. ;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. ;; SOFTWARE.
  21. ;;
  22. ;; Except as contained in this notice, the name of the XFree86 Project shall
  23. ;; not be used in advertising or otherwise to promote the sale, use or other
  24. ;; dealings in this Software without prior written authorization from the
  25. ;; XFree86 Project.
  26. ;;
  27. ;; Author: Paulo CΘsar Pereira de Andrade
  28. ;;
  29. ;;
  30. ;; $XFree86: xc/programs/xedit/lisp/modules/fun.lsp,v 1.5 2001/10/20 00:19:36 paulo Exp $
  31. ;;
  32. (provide "fun")
  33.  
  34. (defun caar (a)        (car (car a)))
  35. (defun cadr (a)        (nth 1 a))
  36. (defun cdar (a)        (cdr (car a)))
  37. (defun cddr (a)        (nthcdr 2 a))
  38. (defun caaar (a)    (car (car (car a))))
  39. (defun caadr (a)    (car (car (cdr a))))
  40. (defun cadar (a)    (car (cdr (car a))))
  41. (defun caddr (a)    (nth 2 a))
  42. (defun cdaar (a)    (cdr (car (car a))))
  43. (defun cdadr (a)    (cdr (car (cdr a))))
  44. (defun cddar (a)    (cdr (cdr (car a))))
  45. (defun cdddr (a)    (nthcdr 3 a))
  46. (defun caaaar (a)    (car (car (car (car a)))))
  47. (defun caaadr (a)    (car (car (car (cdr a)))))
  48. (defun caadar (a)    (car (car (cdr (car a)))))
  49. (defun caaddr (a)    (car (car (cdr (cdr a)))))
  50. (defun cadaar (a)    (car (cdr (car (car a)))))
  51. (defun cadadr (a)    (car (cdr (car (cdr a)))))
  52. (defun caddar (a)    (car (cdr (cdr (car a)))))
  53. (defun cadddr (a)    (nth 3 a))
  54. (defun cdaaar (a)    (cdr (car (car (car a)))))
  55. (defun cdaadr (a)    (cdr (car (car (cdr a)))))
  56. (defun cdadar (a)    (cdr (car (cdr (car a)))))
  57. (defun cdaddr (a)    (cdr (car (cdr (cdr a)))))
  58. (defun cddaar (a)    (cdr (cdr (car (car a)))))
  59. (defun cddadr (a)    (cdr (cdr (car (cdr a)))))
  60. (defun cdddar (a)    (cdr (cdr (cdr (car a)))))
  61. (defun cddddr (a)    (nthcdr 4 a))
  62.  
  63. (defun second (a)    (nth 1 a))
  64. (defun third (a)    (nth 2 a))
  65. (defun fourth (a)    (nth 3 a))
  66. (defun fifth (a)    (nth 4 a))
  67. (defun sixth (a)    (nth 5 a))
  68. (defun seventh (a)    (nth 6 a))
  69. (defun eighth (a)    (nth 7 a))
  70. (defun ninth (a)    (nth 8 a))
  71. (defun tenth (a)    (nth 9 a))
  72.  
  73. (defun copy-seq (sequence)    (subseq sequence 0))
  74.  
  75. (defmacro push (object place)
  76.     (list 'setf place (list 'cons object place)))
  77.  
  78. (defmacro pop (place)
  79.     (list 'prog1 (list 'car place) (list 'setf place (list 'cdr place))))
  80.  
  81. (defmacro prog (init &rest body)
  82.     `(block nil (let ,init (tagbody ,@body))))
  83.  
  84. (defmacro prog* (init &rest body)
  85.     `(block nil (let* ,init (tagbody ,@body))))
  86.  
  87. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  88. ;; setf
  89. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  90. (defsetf car (list) (value)    `(progn (rplaca ,list ,value) ,value))
  91. (defsetf cdr (list) (value)    `(progn (rplacd ,list ,value) ,value))
  92.  
  93. (defsetf caar (list) (value)    `(progn (rplaca (car ,list) ,value) ,value))
  94. (defsetf cadr (list) (value)    `(progn (rplaca (cdr ,list) ,value) ,value))
  95. (defsetf cdar (list) (value)    `(progn (rplacd (car ,list) ,value) ,value))
  96. (defsetf cddr (list) (value)    `(progn (rplacd (cdr ,list) ,value) ,value))
  97. (defsetf caaar (list) (value)    `(progn (rplaca (caar ,list) ,value) ,value))
  98. (defsetf caadr (list) (value)    `(progn (rplaca (cadr ,list) ,value) ,value))
  99. (defsetf cadar (list) (value)    `(progn (rplaca (cdar ,list) ,value) ,value))
  100. (defsetf caddr (list) (value)    `(progn (rplaca (cddr ,list) ,value) ,value))
  101. (defsetf cdaar (list) (value)    `(progn (rplacd (caar ,list) ,value) ,value))
  102. (defsetf cdadr (list) (value)    `(progn (rplacd (cadr ,list) ,value) ,value))
  103. (defsetf cddar (list) (value)    `(progn (rplacd (cdar ,list) ,value) ,value))
  104. (defsetf cdddr (list) (value)    `(progn (rplacd (cddr ,list) ,value) ,value))
  105. (defsetf caaaar (list) (value)    `(progn (rplaca (caaar ,list) ,value) ,value))
  106. (defsetf caaadr (list) (value)    `(progn (rplaca (caadr ,list) ,value) ,value))
  107. (defsetf caadar (list) (value)    `(progn (rplaca (cadar ,list) ,value) ,value))
  108. (defsetf caaddr (list) (value)    `(progn (rplaca (caddr ,list) ,value) ,value))
  109. (defsetf cadaar (list) (value)    `(progn (rplaca (cdaar ,list) ,value) ,value))
  110. (defsetf cadadr (list) (value)    `(progn (rplaca (cdadr ,list) ,value) ,value))
  111. (defsetf caddar (list) (value)    `(progn (rplaca (cddar ,list) ,value) ,value))
  112. (defsetf cadddr (list) (value)    `(progn (rplaca (cdddr ,list) ,value) ,value))
  113. (defsetf cdaaar (list) (value)    `(progn (rplacd (caaar ,list) ,value) ,value))
  114. (defsetf cdaadr (list) (value)    `(progn (rplacd (caadr ,list) ,value) ,value))
  115. (defsetf cdadar (list) (value)    `(progn (rplacd (cadar ,list) ,value) ,value))
  116. (defsetf cdaddr (list) (value)    `(progn (rplacd (caddr ,list) ,value) ,value))
  117. (defsetf cddaar (list) (value)    `(progn (rplacd (cdaar ,list) ,value) ,value))
  118. (defsetf cddadr (list) (value)    `(progn (rplacd (cdadr ,list) ,value) ,value))
  119. (defsetf cdddar (list) (value)    `(progn (rplacd (cddar ,list) ,value) ,value))
  120. (defsetf cddddr (list) (value)    `(progn (rplacd (cdddr ,list) ,value) ,value))
  121.  
  122. (defsetf first (list) (value)    `(progn (rplaca ,list ,value) ,value))
  123. (defsetf second (list) (value)    `(progn (rplaca (nthcdr 1 ,list) ,value) ,value))
  124. (defsetf third (list) (value)    `(progn (rplaca (nthcdr 2 ,list) ,value) ,value))
  125. (defsetf fourth (list) (value)    `(progn (rplaca (nthcdr 3 ,list) ,value) ,value))
  126. (defsetf fifth (list) (value)    `(progn (rplaca (nthcdr 4 ,list) ,value) ,value))
  127. (defsetf sixth (list) (value)    `(progn (rplaca (nthcdr 5 ,list) ,value) ,value))
  128. (defsetf seventh (list) (value)    `(progn (rplaca (nthcdr 6 ,list) ,value) ,value))
  129. (defsetf eighth (list) (value)    `(progn (rplaca (nthcdr 7 ,list) ,value) ,value))
  130. (defsetf ninth (list) (value)    `(progn (rplaca (nthcdr 8 ,list) ,value) ,value))
  131. (defsetf tenth (list) (value)    `(progn (rplaca (nthcdr 9 ,list) ,value) ,value))
  132.  
  133. (defsetf rest (list) (value)    `(progn (rplacd ,list ,value) ,value))
  134.  
  135. (defun xedit::nth-store (index list value)
  136.     (rplaca (nthcdr index list) value) value)
  137. (defsetf nth xedit::nth-store)
  138.  
  139. (defsetf aref (array &rest indices) (value)
  140.     `(xedit::vector-store ,array ,@indices ,value))
  141.  
  142. (defsetf get (symbol key &optional default) (value)
  143.     `(xedit::put ,symbol ,key ,value))
  144.  
  145. (defsetf char xedit::char-store)
  146. (defsetf schar xedit::char-store)
  147. (defsetf elt xedit::elt-store)
  148.  
  149. (defsetf subseq (sequence start &optional end) (value)
  150.     `(progn (replace ,sequence ,value :start1 ,start :end1 ,end) ,value))
  151.